﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ApprovalFlow.Models
{
    public class ConnectorDescription : StepDescription
    {
        public override IEnumerable<ExecutionPointer> Builder(WorkflowInstance instance, ExecutionPointer master)
        {
            var pointers = new List<ExecutionPointer>();
            var pointer = new ExecutionPointer
            {
                Id = this.Id,
                PredecessorId = master?.Id,
                InstanceId = instance.InstanceId,
                StepName = this.Name,
                Processor = "connector"
            };
            pointers.Add(pointer);

            if (this.ChildNode is not null)
            {
                var children = this.ChildNode.Builder(instance, pointer);
                pointers.AddRange(children);
            }
            return pointers;
        }
    }
}
